package chapter5.lessons.udpDemo01;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Project ：learn_java
 * @File ：InetAddressDemo01.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/3/12 17:11
 * @Description ：inet的几个常用方法
 */

public class InetAddressDemo01 {
    public static void main(String[] args) throws UnknownHostException {
        // 获取inet对象
        // 填入电脑的主机名
        InetAddress address = InetAddress.getByName("KUMO");
        System.out.println(address);

        String hostName = address.getHostName();
        System.out.println(hostName);

        String hostAddress = address.getHostAddress();
        System.out.println(hostAddress);
    }
}
